package com.campus_activity.campus_activity.controller;


import com.campus_activity.campus_activity.common.R;
import com.campus_activity.campus_activity.domain.dto.LoginDTO;
import com.campus_activity.campus_activity.service.VerifyCodeService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/verify")
@RequiredArgsConstructor
public class VerifyCodeController {

    private final VerifyCodeService verifyCodeService;

    @Operation(summary = "校验验证码")
    @PostMapping("/confirmMessage")
    public R<?> sendMessage(String phone, String code) {
        boolean judge = verifyCodeService.confirmMsg(phone, code);
        if (judge) {
            return R.success("验证码正确");
        }else {
            return R.fail("验证码错误");
        }
    }

    @Operation(summary = "发送验证码")
    @PostMapping("/sendMessage")
    public R<?> sendMessage(String phone) {
        boolean b = verifyCodeService.sendMessage(phone);
        if (b) {
            return R.success("验证码发送成功");
        }else {
            return R.fail("验证码发送失败");
        }
    }

}
